home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / glibc108.gz / glibc108 / glibc-1.08.1 / sysdeps / alpha / __longjmp.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  3KB  |  97 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef __GNUC__
  20. #error This file uses GNU C extensions; you must compile with GCC.
  21. #endif
  22.  
  23. /*#include <setjmp.h>*/
  24. #include "jmp_buf.h"
  25. #define jmp_buf __jmp_buf
  26.  
  27. register long int
  28.   r9 asm ("$9"), r10 asm ("$10"), r11 asm ("$11"), r12 asm ("$12"),
  29.   r13 asm ("$13"), r14 asm ("$14");
  30.  
  31. register long int *fp asm ("$15"), *sp asm ("$30"), *retpc asm ("$26");
  32.  
  33. #if 1                /* XXX */
  34. register double
  35.   f2 asm ("$f2"), f3 asm ("$f3"), f4 asm ("$f4"), f5 asm ("$f5"),
  36.   f6 asm ("$f6"), f7 asm ("$f7"), f8 asm ("$f8"), f9 asm ("$f9");
  37. #endif
  38.  
  39. /* Jump to the position specified by ENV, causing the
  40.    setjmp call there to return VAL, or 1 if VAL is 0.
  41.  
  42.    We declare this function to return an `int';
  43.    in fact, the value being returned is going to the caller of setjmp.  */
  44. volatile void
  45. __longjmp (const jmp_buf env, int val)
  46. {
  47.   /* Restore the integer registers.  */
  48.   r9 = env[0].__9;
  49.   r10 = env[0].__10;
  50.   r11 = env[0].__11;
  51.   r12 = env[0].__12;
  52.   r13 = env[0].__13;
  53.   r14 = env[0].__14;
  54.  
  55. #if 1                /* XXX */
  56.   /* Restore the floating point registers.  */
  57.   f2 = env[0].__f2;
  58.   f3 = env[0].__f3;
  59.   f4 = env[0].__f4;
  60.   f5 = env[0].__f5;
  61.   f6 = env[0].__f6;
  62.   f7 = env[0].__f7;
  63.   f8 = env[0].__f8;
  64.   f9 = env[0].__f9;
  65. #endif
  66.  
  67.   /* Set the return PC to that of setjmp's caller.  */
  68.   retpc = env[0].__pc;
  69.  
  70.   /* Restore the FP and SP of setjmp's caller.  */
  71.   fp = env[0].__fp;
  72.   sp = env[0].__sp;
  73.  
  74.   /* Return VAL (or 1 if VAL is zero) to setjmp's caller.
  75.  
  76.      We use an asm here rather than a normal C return statement
  77.      just in case the compiler wanted to do some stack frobnication
  78.      in the function epilogue.  Since we have already restored
  79.      precisely the FP and SP the desired environment needs,
  80.      we must avoid the compiler doing anything with the stack.  */
  81.  
  82.   while (1)
  83.     {
  84.       /* The loop is just to avoid `volatile function does return' warnings.
  85.      The instruction will only be executed once.  */
  86.  
  87.       register long int retval asm ("$0");
  88.  
  89.       asm volatile
  90.     ("cmoveq %1, 1, %0\n\t"    /* $0 = val ?: 1; */
  91.      "ret $31, (%2), 1"    /* return $0 */
  92.      : "=r" (retval)
  93.      /* The "0" constraint should force VAL into $0.  */
  94.      : "0" (val), "r" (retpc));
  95.     }
  96. }
  97.